﻿Imports System.Data.OleDb
Public Class _Like
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Image.Visible = False
        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("skinConnectionstring").ConnectionString)
        Dim sql = "select * from liketips where reader=@f1 and TipsID=@f2"

        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f2", Request.Params("ID"))
        Dim dr As OleDbDataReader = cmd.ExecuteReader
        If dr.HasRows Then
            Image.Visible = True
            Lik_bt.Visible = False

        Else

            Image.Visible = False
            Lik_bt.Visible = True
        End If

        conn.Close()
       

    End Sub

    Protected Sub Lik_bt_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Lik_bt.Click
        Image.Visible = True
        Lik_bt.Visible = False


        Dim conn As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("skinConnectionstring").ConnectionString)
        Dim sql = "Insert into liketips(TipsID,Reader) values (@f1,@f2)"

        Dim cmd As OleDbCommand = New OleDbCommand(sql, conn)
        conn.Open()
        cmd.Parameters.AddWithValue("@f1", Request.Params("ID"))
        cmd.Parameters.AddWithValue("@f2", User.Identity.Name)
        cmd.ExecuteNonQuery()
        conn.Close()
        cmd.Dispose()
        conn.Dispose()

    End Sub

    End Class